<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: dzapp_base.php 33234 2016-07-09 15:26:14Z mpage $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

if(submitcheck('listsubmit')) {

	if(is_array($_GET['delete'])) {
		C::t('#dzapp_base#dzapp_base_perm')->delete($_GET['delete']);
	}

	if(is_array($_GET['plugin'])) {
		foreach($_GET['plugin'] as $key => $value) {
			C::t('#dzapp_base#dzapp_base_perm')->update($key, array(
				'displayorder' => $_GET['displayorder'][$key],
				'plugin' => $_GET['plugin'][$key],
				'module' => $_GET['module'][$key],
				'user' => $_GET['user'][$key],
				'open' => $_GET['open'][$key],
				'available' => $_GET['available'][$key],
			));
		}
	}

	if(is_array($_GET['newplugin'])) {
		foreach($_GET['newplugin'] as $key => $value) {
			if(empty($value)) continue;
			C::t('#dzapp_base#dzapp_base_perm')->insert(array(
				'displayorder' => $_GET['newdisplayorder'][$key],
				'plugin' => $_GET['newplugin'][$key],
				'module' => $_GET['newmodule'][$key],
				'user' => $_GET['newuser'][$key],
				'open' => $_GET['newopen'][$key],
				'available' => $_GET['newavailable'][$key],
			));
		}
	}

	require_once libfile('function/cache');
	updatecache('dzapp_base:dzapp_base_perm');

	showmessage('operation_done', 'plugin.php?id=dzapp_base&mod=basecp&ac=perm');
}

$list = C::t('#dzapp_base#dzapp_base_perm')->fetch_all_by_condition(array(), 0, 0, 'displayorder', 'ASC', 'perm_id');

include_once template('dzapp_base:basecp_perm');

?>